package com.sky.controller.user;

import com.sky.dto.ShoppingCartDTO;
import com.sky.result.Result;
import com.sky.service.ShoppingCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "购物车相关接口")
@RequestMapping("/user/shoppingCart")
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;

    @PostMapping("/add")
    @ApiOperation("添加购物车")
    public Result addCart(@RequestBody ShoppingCartDTO dto){
        return shoppingCartService.addCart(dto);
    }

    @GetMapping("/list")
    @ApiOperation("查看购物车")
    public Result queryCart(){
        return shoppingCartService.queryCart();
    }

    @DeleteMapping("/clean")
    @ApiOperation("清除购物车")
    public Result cleanCart(){
        return shoppingCartService.cleanCart();
    }
}
